home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / MPW_TOOL / TOOLS / TOOLS_WI / ICON_8 / ICONX_FO / RMEMFIX.C < prev    next >
Text File  |  1990-03-02  |  2KB  |  77 lines

  1. /*
  2.  * File: rmemfix.c - memory managemnt functions for fixed regions
  3.  *  Contents: initalloc, reclaim
  4.  */
  5.  
  6. /*
  7.  * Prototype.
  8.  */
  9.  
  10. hidden    novalue reclaim    Params((int region));
  11.  
  12. /*
  13.  * initalloc - initialization routine to allocate memory regions
  14.  */
  15.  
  16. novalue initalloc(codesize)
  17. word codesize;
  18.    {
  19.    static char dummy[1];    /* dummy static region */
  20.  
  21.    /*
  22.     * Allocate icode region
  23.     */
  24.    if ((code = (char *)AllocReg(codesize)) == NULL)
  25.       error("insufficient memory for icode");
  26.  
  27.    /*
  28.     * Set up allocated memory.    The regions are:
  29.   
  30.     *    Static memory region (not used)
  31.     *    Allocated string region
  32.     *    Allocate block region
  33.     *    Qualifier list
  34.     */
  35.  
  36.    statend = statfree = statbase = dummy;
  37.    if ((strfree = strbase = (char *)AllocReg(ssize)) == NULL)
  38.       error("insufficient memory for string region");
  39.    strend = strbase + ssize;
  40.    if ((blkfree = blkbase = (char *)AllocReg(abrsize)) == NULL)
  41.       error("insufficient memory for block region");
  42.    blkend = blkbase + abrsize;
  43.    if ((quallist = (dptr *)AllocReg(qualsize)) == NULL)
  44.       error("insufficient memory qualifier list");
  45.    equallist = (dptr *)((char *)quallist + qualsize);
  46.    }
  47.  
  48. /*
  49.  * reclaim - reclaim space in the allocated memory regions. The marking
  50.  *   phase has already been completed.
  51.  */
  52.  
  53. static novalue reclaim(region)
  54. int region;
  55.    {
  56.    /*
  57.     * Collect available co-expression blocks.
  58.     */
  59.    cofree();
  60.  
  61.    /*
  62.     * Collect the string space leaving it where it is.
  63.     */
  64.    if (!qualfail)
  65.       scollect((word)0);
  66.  
  67.    /*
  68.     * Adjust the blocks in the block region in place.
  69.     */
  70.    adjust(blkbase,blkbase);
  71.  
  72.    /*
  73.     * Compact the block region.
  74.     */
  75.    compact(blkbase);
  76.    }
  77.